// let url = 'http://cnady.natapp1.cc/CandyFirst_war_exploded/message/index'
let url = 'http://47.96.224.206:8080/CandyFirst/message/index'

$.post(url, function (res) {
    console.log(res)
    var str = ''
    $.map(res, function (v, i) {
        console.log(v, i)
        let time0 = res[i].time //返回的毫秒数
        // console.log(Date.parse(new Date),time0)
        // console.log(Date.parse(new Date) - time0)
        d_s = (Date.parse(new Date) - time0) / 1000
        //d_s相差多少秒
        if (d_s > 3600 * 24) {
            d_ = parseInt(d_s / 3600 / 24) + "天前"
        } else if (d_s > 3600) {
            d_ = parseInt(d_s / 3600) + "小时前"
        } else if (d_s > 60) {
            d_ = parseInt(d_s / 60) + "分钟前"
        } else {
            d_ = "不到1分钟"
        }
        //输出 d_ 就行,字符串

        str += `
        <div class="box tiao">
            <p>${v.title}>></p>
             <div><img src="${v.mesImage}"></div>
            <span>${d_}</span>
        </div>
        `       
    })
    $('section').html(str)
    console.log($('.tiao').length)
    $('.tiao').click(function(){
        $(location).attr('href','xiaRi.html')
    })

})